/*  
 *   *  hello-2.c - Demonstrating the module_init() and module_exit() macros.
 *    *  This is preferred over using init_module() and cleanup_module().
 *     */
#include <linux/module.h>	/* Needed by all modules */
#include <linux/moduleparam.h>
#include <linux/kernel.h>	/* Needed for KERN_INFO */
#include <linux/init.h>		/* Needed for the macros */
#include <linux/stat.h>
#include "plog.h"
#include "comm_interface/comm_interface.h"
#include "scan_task.h"

int citype = PCI_PROC;
//module_param(citype, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
module_param(citype, int, 0);
MODULE_PARM_DESC(citype, "proc communication type");

static char *procfile= "dt_log";
module_param(procfile, charp, 0);
MODULE_PARM_DESC(procfile, "proc file name");

static struct PCI_CONFIG config;

static int __init dt_log_init(void){
	int ret = 0;
	printk(KERN_INFO "begin init dt_log\n");
	strncpy( config.proc_file, procfile, 256 );
	ret = register_interface( citype, &config);
	if( 0 != ret ){
		LOGF("register communication interface failed!");
		goto out;
	}
	ret = scan_thread_start();
	if( 0 != ret ){
		LOGF("create scan thread failed!");
	}	
out:
	printk(KERN_INFO "end init dt_log ret:%d\n", ret);
	return ret;
}

static void __exit dt_log_exit(void){
	scan_thread_stop();
	printk(KERN_INFO "Goodbye, world 2\n");
	return;
}

module_init(dt_log_init);
module_exit(dt_log_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Miles.zhaof miles.zhaof@aliyun-inc.com");
MODULE_DESCRIPTION("dynamic trace logger");
